From 89eef49cadaf7cc363cb85597f9bc881304ab7c5 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Tue, 17 Dec 2019 07:23:05 -0700 Subject: [PATCH] Fix potential slicing with Filter class. (#440) detected by clazy as: warning: Polymorphic class Filter is copyable. Potential slicing. [-Wclazy-copyable-polymorphic] --- filter.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/filter.h b/filter.h index 6147afa74..3d3d68935 100644 --- a/filter.h +++ b/filter.h @@ -35,12 +35,13 @@ public: // its base class type. // https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP52-CPP.+Do+not+delete+a+polymorphic+object+without+a+virtual+destructor virtual ~Filter() = default; - // And that requires us to explicitly default the move and copy operations. + // And that requires us to explicitly default or delete the move and copy operations. + // To prevent slicing we delete them. // https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c21-if-you-define-or-delete-any-default-operation-define-or-delete-them-all. - Filter(const Filter&) = default; - Filter& operator=(const Filter&) = default; - Filter(Filter&&) = default; - Filter& operator=(Filter&&) = default; + Filter(const Filter&) = delete; + Filter& operator=(const Filter&) = delete; + Filter(Filter&&) = delete; + Filter& operator=(Filter&&) = delete; virtual QVector* get_args() = 0; -- 2.30.2